package java_jdbc;
import java.sql.*;
import java.util.Scanner;

import util.DBUtil;

public class jdbc5 {

	public static void main(String[] args) {

		Connection con = DBUtil.getConnection();
		PreparedStatement st = null;

		try {

			Scanner in = new Scanner(System.in);
			System.out.println("请输入学生学号、姓名、性别、电话号、qq、微信、年级号、入学日期、城市、生日、地址、密码");
			int stuno = in.nextInt();
			String name = in.next();
			String sex = in.next();
			String tele = in.next();
			int qq = in.nextInt();
			String wechat = in.next();
			int gradeid = in.nextInt();
			String enterdate = in.next();
			String fromcity = in.next();
			String birthday = in.next();
			String address = in.next();
			String pass = in.next();

			String sq1 = "insert into s_student (stuno,sname,sex,telephone,qq,wechat,gradeid,enterdate,fromcity,birthday,address,pass) "
					+ "values(?,?,?,?,?,?,?,?,?,?,?,?)";

			st = con.prepareStatement(sq1);

			st.setInt(1, stuno);
			st.setString(2, name);
			st.setString(3, sex);
			st.setString(4, tele);
			st.setInt(5, qq);
			st.setString(6, wechat);
			st.setInt(7, gradeid);
			st.setString(8, enterdate);
			st.setString(9, fromcity);
			st.setString(10, birthday);
			st.setString(11, address);
			st.setString(12, pass);

			System.out.println(sq1);
			int r = st.executeUpdate();
			System.out.println(String.format("增加了%d条数据", r));

		} catch (SQLException e) {

			e.printStackTrace();
		} finally {

			DBUtil.close(null, st, con);
		}
	}
}